.class public final Lcom/ninesky/browser/provider/downloads/g;
.super Ljava/lang/Object;


# static fields
.field public static a:Ljava/util/Random;

.field private static final b:Ljava/util/regex/Pattern;


# direct methods
.method static constructor <clinit>()V
    .locals 3

    new-instance v0, Ljava/util/Random;

    invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J

    move-result-wide v1

    invoke-direct {v0, v1, v2}, Ljava/util/Random;-><init>(J)V

    sput-object v0, Lcom/ninesky/browser/provider/downloads/g;->a:Ljava/util/Random;

    const-string v0, "attachment;\\s*filename\\s*=\\s*\"([^\"]*)\""

    invoke-static {v0}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v0

    sput-object v0, Lcom/ninesky/browser/provider/downloads/g;->b:Ljava/util/regex/Pattern;

    return-void
.end method

.method private constructor <init>()V
    .locals 0

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static a(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IJZ)Lcom/ninesky/browser/provider/downloads/v;
    .locals 5

    if-nez p9, :cond_2

    if-eqz p6, :cond_0

    const/4 p9, 0x2

    if-ne p6, p9, :cond_2

    :cond_0
    if-nez p5, :cond_1

    const/4 p9, 0x0

    :goto_0
    if-nez p9, :cond_3

    new-instance p0, Lcom/ninesky/browser/provider/downloads/v;

    const/4 p1, 0x0

    const/4 p2, 0x0

    const/16 p3, 0x196

    invoke-direct {p0, p1, p2, p3}, Lcom/ninesky/browser/provider/downloads/v;-><init>(Ljava/lang/String;Ljava/io/FileOutputStream;I)V

    :goto_1
    return-object p0

    :cond_1
    const-string p9, "application/vnd.oma.drm.message"

    invoke-virtual {p9, p5}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result p9

    if-nez p9, :cond_2

    new-instance p9, Landroid/content/Intent;

    const-string v0, "android.intent.action.VIEW"

    invoke-direct {p9, v0}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    invoke-virtual {p0}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v0

    const-string v1, "file"

    const-string v2, ""

    const/4 v3, 0x0

    invoke-static {v1, v2, v3}, Landroid/net/Uri;->fromParts(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    invoke-virtual {p9, v1, p5}, Landroid/content/Intent;->setDataAndType(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;

    const/high16 v1, 0x1

    invoke-virtual {v0, p9, v1}, Landroid/content/pm/PackageManager;->resolveActivity(Landroid/content/Intent;I)Landroid/content/pm/ResolveInfo;

    move-result-object p9

    if-nez p9, :cond_2

    const/4 p9, 0x0

    goto :goto_0

    :cond_2
    const/4 p9, 0x1

    goto :goto_0

    :cond_3
    const/4 p9, 0x4

    if-ne p6, p9, :cond_4

    :try_start_0
    invoke-static {p2}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object p0

    invoke-virtual {p0}, Landroid/net/Uri;->getSchemeSpecificPart()Ljava/lang/String;

    move-result-object p0

    new-instance p1, Ljava/io/File;

    invoke-direct {p1, p0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {p1}, Ljava/io/File;->exists()Z

    move-result p1

    if-eqz p1, :cond_9

    const-string p1, "DownloadManager"

    new-instance p2, Ljava/lang/StringBuilder;

    const-string p3, "File already exists: "

    invoke-direct {p2, p3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {p2, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object p0

    invoke-virtual {p0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p0

    invoke-static {p1, p0}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    new-instance p0, Lcom/ninesky/browser/provider/downloads/t;

    const/16 p1, 0x1ec

    invoke-direct {p0, p1}, Lcom/ninesky/browser/provider/downloads/t;-><init>(I)V

    throw p0
    :try_end_0
    .catch Lcom/ninesky/browser/provider/downloads/t; {:try_start_0 .. :try_end_0} :catch_0

    :catch_0
    move-exception p0

    new-instance p1, Lcom/ninesky/browser/provider/downloads/v;

    const/4 p2, 0x0

    const/4 p3, 0x0

    iget p0, p0, Lcom/ninesky/browser/provider/downloads/t;->a:I

    invoke-direct {p1, p2, p3, p0}, Lcom/ninesky/browser/provider/downloads/v;-><init>(Ljava/lang/String;Ljava/io/FileOutputStream;I)V

    move-object p0, p1

    goto :goto_1

    :cond_4
    :try_start_1
    invoke-static {p0, p5, p6, p7, p8}, Lcom/ninesky/browser/provider/downloads/g;->a(Landroid/content/Context;Ljava/lang/String;IJ)Ljava/io/File;

    move-result-object p0

    const/4 p7, 0x0

    if-eqz p2, :cond_10

    const-string p8, "/"

    invoke-virtual {p2, p8}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result p8

    if-nez p8, :cond_10

    const/16 p7, 0x2f

    invoke-virtual {p2, p7}, Ljava/lang/String;->lastIndexOf(I)I

    move-result p7

    add-int/lit8 p7, p7, 0x1

    if-lez p7, :cond_5

    invoke-virtual {p2, p7}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object p2

    :cond_5
    :goto_2
    if-nez p2, :cond_6

    if-eqz p3, :cond_6

    invoke-static {p3}, Lcom/ninesky/browser/provider/downloads/g;->b(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p2

    if-eqz p2, :cond_6

    const/16 p3, 0x2f

    invoke-virtual {p2, p3}, Ljava/lang/String;->lastIndexOf(I)I

    move-result p3

    add-int/lit8 p3, p3, 0x1

    if-lez p3, :cond_6

    invoke-virtual {p2, p3}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object p2

    :cond_6
    if-nez p2, :cond_7

    if-eqz p4, :cond_7

    invoke-static {p4}, Landroid/net/Uri;->decode(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p3

    if-eqz p3, :cond_7

    const-string p4, "/"

    invoke-virtual {p3, p4}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result p4

    if-nez p4, :cond_7

    const/16 p4, 0x3f

    invoke-virtual {p3, p4}, Ljava/lang/String;->indexOf(I)I

    move-result p4

    if-gez p4, :cond_7

    const/16 p2, 0x2f

    invoke-virtual {p3, p2}, Ljava/lang/String;->lastIndexOf(I)I

    move-result p2

    add-int/lit8 p2, p2, 0x1

    if-lez p2, :cond_a

    invoke-virtual {p3, p2}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object p2

    :cond_7
    :goto_3
    if-nez p2, :cond_f

    invoke-static {p1}, Landroid/net/Uri;->decode(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p1

    if-eqz p1, :cond_f

    const-string p3, "/"

    invoke-virtual {p1, p3}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result p3

    if-nez p3, :cond_f

    const/16 p3, 0x3f

    invoke-virtual {p1, p3}, Ljava/lang/String;->indexOf(I)I

    move-result p3

    if-gez p3, :cond_f

    const/16 p3, 0x2f

    invoke-virtual {p1, p3}, Ljava/lang/String;->lastIndexOf(I)I

    move-result p3

    add-int/lit8 p3, p3, 0x1

    if-lez p3, :cond_f

    invoke-virtual {p1, p3}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object p1

    :goto_4
    if-nez p1, :cond_8

    const-string p1, "downloadfile"

    :cond_8
    invoke-static {p1}, Lcom/ninesky/browser/provider/downloads/g;->c(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p1

    const/16 p2, 0x2e

    invoke-virtual {p1, p2}, Ljava/lang/String;->indexOf(I)I

    move-result p2

    if-gez p2, :cond_b

    const/4 p2, 0x1

    invoke-static {p5, p2}, Lcom/ninesky/browser/provider/downloads/g;->a(Ljava/lang/String;Z)Ljava/lang/String;

    move-result-object p2

    move-object v4, p2

    move-object p2, p1

    move-object p1, v4

    :goto_5
    const-string p3, "recovery"

    new-instance p4, Ljava/lang/StringBuilder;

    invoke-static {p2}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object p5

    invoke-direct {p4, p5}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {p4, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object p4

    invoke-virtual {p4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p4

    invoke-virtual {p3, p4}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result p3

    new-instance p4, Ljava/lang/StringBuilder;

    invoke-virtual {p0}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object p0

    invoke-static {p0}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object p0

    invoke-direct {p4, p0}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    sget-object p0, Ljava/io/File;->separator:Ljava/lang/String;

    invoke-virtual {p4, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object p0

    invoke-virtual {p0, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object p0

    invoke-virtual {p0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p0

    invoke-static {p6, p0, p1, p3}, Lcom/ninesky/browser/provider/downloads/g;->a(ILjava/lang/String;Ljava/lang/String;Z)Ljava/lang/String;
    :try_end_1
    .catch Lcom/ninesky/browser/provider/downloads/t; {:try_start_1 .. :try_end_1} :catch_0

    move-result-object p0

    :cond_9
    new-instance p1, Lcom/ninesky/browser/provider/downloads/v;

    new-instance p2, Ljava/io/FileOutputStream;

    invoke-direct {p2, p0}, Ljava/io/FileOutputStream;-><init>(Ljava/lang/String;)V

    const/4 p3, 0x0

    invoke-direct {p1, p0, p2, p3}, Lcom/ninesky/browser/provider/downloads/v;-><init>(Ljava/lang/String;Ljava/io/FileOutputStream;I)V

    move-object p0, p1

    goto/16 :goto_1

    :cond_a
    move-object p2, p3

    goto/16 :goto_3

    :cond_b
    const/4 p3, 0x0

    if-eqz p5, :cond_d

    const/16 p4, 0x2e

    :try_start_2
    invoke-virtual {p1, p4}, Ljava/lang/String;->lastIndexOf(I)I

    move-result p4

    invoke-static {}, Landroid/webkit/MimeTypeMap;->getSingleton()Landroid/webkit/MimeTypeMap;

    move-result-object p7

    add-int/lit8 p4, p4, 0x1

    invoke-virtual {p1, p4}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object p4

    invoke-virtual {p7, p4}, Landroid/webkit/MimeTypeMap;->getMimeTypeFromExtension(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p4

    if-eqz p4, :cond_c

    invoke-virtual {p4, p5}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result p4

    if-nez p4, :cond_d

    :cond_c
    const/4 p3, 0x0

    invoke-static {p5, p3}, Lcom/ninesky/browser/provider/downloads/g;->a(Ljava/lang/String;Z)Ljava/lang/String;

    move-result-object p3

    :cond_d
    if-nez p3, :cond_e

    invoke-virtual {p1, p2}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object p3

    :cond_e
    const/4 p4, 0x0

    invoke-virtual {p1, p4, p2}, Ljava/lang/String;->substring(II)Ljava/lang/String;
    :try_end_2
    .catch Lcom/ninesky/browser/provider/downloads/t; {:try_start_2 .. :try_end_2} :catch_0

    move-result-object p1

    move-object p2, p1

    move-object p1, p3

    goto :goto_5

    :cond_f
    move-object p1, p2

    goto/16 :goto_4

    :cond_10
    move-object p2, p7

    goto/16 :goto_2
.end method

.method private static a(Landroid/content/Context;Ljava/lang/String;IJ)Ljava/io/File;
    .locals 10

    const/16 v9, 0x1f2

    const-wide/16 v7, 0x4

    const/4 v0, 0x1

    if-eq p2, v0, :cond_0

    const/4 v0, 0x2

    if-eq p2, v0, :cond_0

    const/4 v0, 0x3

    if-eq p2, v0, :cond_0

    const-string v0, "application/vnd.oma.drm.message"

    invoke-virtual {v0, p1}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_3

    :cond_0
    invoke-static {}, Landroid/os/Environment;->getDownloadCacheDirectory()Ljava/io/File;

    move-result-object v0

    new-instance v1, Landroid/os/StatFs;

    invoke-virtual {v0}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Landroid/os/StatFs;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1}, Landroid/os/StatFs;->getBlockSize()I

    move-result v2

    int-to-long v3, v2

    invoke-virtual {v1}, Landroid/os/StatFs;->getAvailableBlocks()I

    move-result v5

    int-to-long v5, v5

    sub-long/2addr v5, v7

    mul-long/2addr v3, v5

    :goto_0
    cmp-long v5, v3, p3

    if-ltz v5, :cond_1

    :goto_1
    return-object v0

    :cond_1
    sub-long v3, p3, v3

    invoke-static {p0, v3, v4}, Lcom/ninesky/browser/provider/downloads/g;->a(Landroid/content/Context;J)Z

    move-result v3

    if-nez v3, :cond_2

    new-instance v0, Lcom/ninesky/browser/provider/downloads/t;

    invoke-direct {v0, v9}, Lcom/ninesky/browser/provider/downloads/t;-><init>(I)V

    throw v0

    :cond_2
    invoke-virtual {v0}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v1, v3}, Landroid/os/StatFs;->restat(Ljava/lang/String;)V

    int-to-long v3, v2

    invoke-virtual {v1}, Landroid/os/StatFs;->getAvailableBlocks()I

    move-result v5

    int-to-long v5, v5

    sub-long/2addr v5, v7

    mul-long/2addr v3, v5

    goto :goto_0

    :cond_3
    invoke-static {}, Landroid/os/Environment;->getExternalStorageState()Ljava/lang/String;

    move-result-object v0

    const-string v1, "mounted"

    invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_5

    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v0

    invoke-virtual {v0}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v0

    new-instance v1, Landroid/os/StatFs;

    invoke-direct {v1, v0}, Landroid/os/StatFs;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1}, Landroid/os/StatFs;->getBlockSize()I

    move-result v2

    int-to-long v2, v2

    invoke-virtual {v1}, Landroid/os/StatFs;->getAvailableBlocks()I

    move-result v1

    int-to-long v4, v1

    sub-long/2addr v4, v7

    mul-long v1, v2, v4

    cmp-long v1, v1, p3

    if-gez v1, :cond_4

    new-instance v0, Lcom/ninesky/browser/provider/downloads/t;

    invoke-direct {v0, v9}, Lcom/ninesky/browser/provider/downloads/t;-><init>(I)V

    throw v0

    :cond_4
    new-instance v1, Ljava/io/File;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v0}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v0

    invoke-direct {v2, v0}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v0, "/ninesky/download"

    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-direct {v1, v0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1}, Ljava/io/File;->isDirectory()Z

    move-result v0

    if-nez v0, :cond_6

    invoke-virtual {v1}, Ljava/io/File;->mkdirs()Z

    move-result v0

    if-nez v0, :cond_6

    new-instance v0, Lcom/ninesky/browser/provider/downloads/t;

    const/16 v1, 0x1ec

    invoke-direct {v0, v1}, Lcom/ninesky/browser/provider/downloads/t;-><init>(I)V

    throw v0

    :cond_5
    new-instance v0, Lcom/ninesky/browser/provider/downloads/t;

    const/16 v1, 0x1f3

    invoke-direct {v0, v1}, Lcom/ninesky/browser/provider/downloads/t;-><init>(I)V

    throw v0

    :cond_6
    move-object v0, v1

    goto/16 :goto_1
.end method

.method private static a(ILjava/lang/String;Ljava/lang/String;Z)Ljava/lang/String;
    .locals 7

    const/4 v2, 0x1

    new-instance v0, Ljava/lang/StringBuilder;

    invoke-static {p1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    new-instance v1, Ljava/io/File;

    invoke-direct {v1, v0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1}, Ljava/io/File;->exists()Z

    move-result v1

    if-nez v1, :cond_1

    if-eqz p3, :cond_0

    if-eq p0, v2, :cond_1

    const/4 v1, 0x2

    if-eq p0, v1, :cond_1

    const/4 v1, 0x3

    if-eq p0, v1, :cond_1

    :cond_0
    :goto_0
    return-object v0

    :cond_1
    new-instance v0, Ljava/lang/StringBuilder;

    invoke-static {p1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v1, "-"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    move v1, v2

    :goto_1
    const v3, 0x3b9aca00

    if-lt v1, v3, :cond_2

    new-instance v0, Lcom/ninesky/browser/provider/downloads/t;

    const/16 v1, 0x1ec

    invoke-direct {v0, v1}, Lcom/ninesky/browser/provider/downloads/t;-><init>(I)V

    throw v0

    :cond_2
    const/4 v3, 0x0

    move v6, v3

    move v3, v2

    move v2, v6

    :goto_2
    const/16 v4, 0x9

    if-lt v2, v4, :cond_3

    mul-int/lit8 v1, v1, 0xa

    move v2, v3

    goto :goto_1

    :cond_3
    new-instance v4, Ljava/lang/StringBuilder;

    invoke-static {v0}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    invoke-direct {v4, v5}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v4, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    new-instance v5, Ljava/io/File;

    invoke-direct {v5, v4}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v5}, Ljava/io/File;->exists()Z

    move-result v5

    if-nez v5, :cond_4

    move-object v0, v4

    goto :goto_0

    :cond_4
    sget-object v4, Lcom/ninesky/browser/provider/downloads/g;->a:Ljava/util/Random;

    invoke-virtual {v4, v1}, Ljava/util/Random;->nextInt(I)I

    move-result v4

    add-int/lit8 v4, v4, 0x1

    add-int/2addr v3, v4

    add-int/lit8 v2, v2, 0x1

    goto :goto_2
.end method

.method private static a(Ljava/lang/String;Z)Ljava/lang/String;
    .locals 3

    const/4 v0, 0x0

    if-eqz p0, :cond_0

    invoke-static {}, Landroid/webkit/MimeTypeMap;->getSingleton()Landroid/webkit/MimeTypeMap;

    move-result-object v0

    invoke-virtual {v0, p0}, Landroid/webkit/MimeTypeMap;->getExtensionFromMimeType(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    if-eqz v0, :cond_0

    new-instance v1, Ljava/lang/StringBuilder;

    const-string v2, "."

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    :cond_0
    if-nez v0, :cond_1

    if-eqz p0, :cond_3

    invoke-virtual {p0}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v1

    const-string v2, "text/"

    invoke-virtual {v1, v2}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_3

    const-string v1, "text/html"

    invoke-virtual {p0, v1}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_2

    const-string v0, ".html"

    :cond_1
    :goto_0
    return-object v0

    :cond_2
    if-eqz p1, :cond_1

    const-string v0, ".txt"

    goto :goto_0

    :cond_3
    if-eqz p1, :cond_1

    const-string v0, ".bin"

    goto :goto_0
.end method

.method private static a(Lcom/ninesky/browser/provider/downloads/c;)V
    .locals 2

    :goto_0
    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->a()I

    move-result v0

    const/4 v1, 0x1

    if-ne v0, v1, :cond_1

    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->b()V

    invoke-static {p0}, Lcom/ninesky/browser/provider/downloads/g;->a(Lcom/ninesky/browser/provider/downloads/c;)V

    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->a()I

    move-result v0

    const/4 v1, 0x2

    if-eq v0, v1, :cond_0

    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "syntax error, unmatched parenthese"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    :cond_0
    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->b()V

    :goto_1
    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->a()I

    move-result v0

    const/4 v1, 0x3

    if-ne v0, v1, :cond_7

    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->b()V

    goto :goto_0

    :cond_1
    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->a()I

    move-result v0

    const/4 v1, 0x4

    if-eq v0, v1, :cond_2

    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "syntax error, expected column name"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    :cond_2
    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->b()V

    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->a()I

    move-result v0

    const/4 v1, 0x5

    if-ne v0, v1, :cond_4

    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->b()V

    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->a()I

    move-result v0

    const/4 v1, 0x6

    if-eq v0, v1, :cond_3

    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "syntax error, expected quoted string"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    :cond_3
    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->b()V

    goto :goto_1

    :cond_4
    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->a()I

    move-result v0

    const/4 v1, 0x7

    if-ne v0, v1, :cond_6

    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->b()V

    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->a()I

    move-result v0

    const/16 v1, 0x8

    if-eq v0, v1, :cond_5

    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "syntax error, expected NULL"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    :cond_5
    invoke-virtual {p0}, Lcom/ninesky/browser/provider/downloads/c;->b()V

    goto :goto_1

    :cond_6
    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "syntax error after column name"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    :cond_7
    return-void
.end method

.method public static a(Ljava/lang/String;Ljava/util/Set;)V
    .locals 2

    :try_start_0
    invoke-static {p0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v0

    if-eqz v0, :cond_1

    :cond_0
    return-void

    :cond_1
    new-instance v0, Lcom/ninesky/browser/provider/downloads/c;

    invoke-direct {v0, p0, p1}, Lcom/ninesky/browser/provider/downloads/c;-><init>(Ljava/lang/String;Ljava/util/Set;)V

    invoke-static {v0}, Lcom/ninesky/browser/provider/downloads/g;->a(Lcom/ninesky/browser/provider/downloads/c;)V

    invoke-virtual {v0}, Lcom/ninesky/browser/provider/downloads/c;->a()I

    move-result v0

    const/16 v1, 0x9

    if-eq v0, v1, :cond_0

    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "syntax error"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0
    :try_end_0
    .catch Ljava/lang/RuntimeException; {:try_start_0 .. :try_end_0} :catch_0

    :catch_0
    move-exception v0

    throw v0
.end method

.method public static final a(Landroid/content/Context;J)Z
    .locals 10

    const-wide/16 v8, 0x0

    const/4 v7, 0x0

    const/4 v2, 0x0

    invoke-virtual {p0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v0

    sget-object v1, Lcom/ninesky/browser/provider/downloads/w;->a:Landroid/net/Uri;

    const-string v3, "( status = \'200\' AND destination = \'2\' )"

    const-string v5, "lastmod"

    move-object v4, v2

    invoke-virtual/range {v0 .. v5}, Landroid/content/ContentResolver;->query(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    if-nez v0, :cond_0

    move v0, v7

    :goto_0
    return v0

    :cond_0
    :try_start_0
    invoke-interface {v0}, Landroid/database/Cursor;->moveToFirst()Z

    move-wide v1, v8

    :goto_1
    invoke-interface {v0}, Landroid/database/Cursor;->isAfterLast()Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    move-result v3

    if-nez v3, :cond_1

    cmp-long v3, v1, p1

    if-ltz v3, :cond_2

    :cond_1
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    cmp-long v0, v1, v8

    if-lez v0, :cond_3

    const/4 v0, 0x1

    goto :goto_0

    :cond_2
    :try_start_1
    new-instance v3, Ljava/io/File;

    const-string v4, "_data"

    invoke-interface {v0, v4}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v4

    invoke-interface {v0, v4}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v4

    invoke-direct {v3, v4}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v3}, Ljava/io/File;->length()J

    move-result-wide v4

    add-long/2addr v1, v4

    invoke-virtual {v3}, Ljava/io/File;->delete()Z

    const-string v3, "_id"

    invoke-interface {v0, v3}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v3

    invoke-interface {v0, v3}, Landroid/database/Cursor;->getLong(I)J

    move-result-wide v3

    invoke-virtual {p0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v5

    sget-object v6, Lcom/ninesky/browser/provider/downloads/w;->a:Landroid/net/Uri;

    invoke-static {v6, v3, v4}, Landroid/content/ContentUris;->withAppendedId(Landroid/net/Uri;J)Landroid/net/Uri;

    move-result-object v3

    const/4 v4, 0x0

    const/4 v6, 0x0

    invoke-virtual {v5, v3, v4, v6}, Landroid/content/ContentResolver;->delete(Landroid/net/Uri;Ljava/lang/String;[Ljava/lang/String;)I

    invoke-interface {v0}, Landroid/database/Cursor;->moveToNext()Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_1

    :catchall_0
    move-exception v1

    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    throw v1

    :cond_3
    move v0, v7

    goto :goto_0
.end method

.method public static a(Lcom/ninesky/browser/provider/downloads/l;)Z
    .locals 1

    invoke-interface {p0}, Lcom/ninesky/browser/provider/downloads/l;->b()Ljava/lang/Integer;

    move-result-object v0

    if-eqz v0, :cond_0

    const/4 v0, 0x1

    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public static a(Ljava/lang/String;)Z
    .locals 2

    const-string v0, "/+"

    const-string v1, "/"

    invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replaceFirst(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    invoke-static {}, Landroid/os/Environment;->getDownloadCacheDirectory()Ljava/io/File;

    move-result-object v1

    invoke-virtual {v1}, Ljava/io/File;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v1

    if-nez v1, :cond_0

    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v1

    invoke-virtual {v1}, Ljava/io/File;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v0

    if-nez v0, :cond_0

    const/4 v0, 0x0

    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x1

    goto :goto_0
.end method

.method private static b(Ljava/lang/String;)Ljava/lang/String;
    .locals 2

    :try_start_0
    sget-object v0, Lcom/ninesky/browser/provider/downloads/g;->b:Ljava/util/regex/Pattern;

    invoke-virtual {v0, p0}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;

    move-result-object v0

    invoke-virtual {v0}, Ljava/util/regex/Matcher;->find()Z

    move-result v1

    if-eqz v1, :cond_0

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Ljava/util/regex/Matcher;->group(I)Ljava/lang/String;
    :try_end_0
    .catch Ljava/lang/IllegalStateException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v0

    :goto_0
    return-object v0

    :catch_0
    move-exception v0

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method private static c(Ljava/lang/String;)Ljava/lang/String;
    .locals 6

    const/4 v5, 0x0

    new-instance v0, Ljava/lang/StringBuffer;

    invoke-direct {v0}, Ljava/lang/StringBuffer;-><init>()V

    move v1, v5

    move v2, v5

    :goto_0
    invoke-virtual {p0}, Ljava/lang/String;->length()I

    move-result v3

    if-lt v1, v3, :cond_0

    invoke-virtual {v0}, Ljava/lang/StringBuffer;->toString()Ljava/lang/String;

    move-result-object v0

    return-object v0

    :cond_0
    invoke-virtual {p0, v1}, Ljava/lang/String;->charAt(I)C

    move-result v3

    if-ltz v3, :cond_1

    const/16 v4, 0x1f

    if-le v3, v4, :cond_2

    :cond_1
    const/16 v4, 0x22

    if-eq v3, v4, :cond_2

    const/16 v4, 0x2a

    if-eq v3, v4, :cond_2

    const/16 v4, 0x2f

    if-eq v3, v4, :cond_2

    const/16 v4, 0x3a

    if-eq v3, v4, :cond_2

    const/16 v4, 0x3c

    if-eq v3, v4, :cond_2

    const/16 v4, 0x3e

    if-eq v3, v4, :cond_2

    const/16 v4, 0x3f

    if-eq v3, v4, :cond_2

    const/16 v4, 0x5c

    if-eq v3, v4, :cond_2

    const/16 v4, 0x7c

    if-eq v3, v4, :cond_2

    const/16 v4, 0x7f

    if-ne v3, v4, :cond_4

    :cond_2
    if-nez v2, :cond_3

    const/16 v2, 0x5f

    invoke-virtual {v0, v2}, Ljava/lang/StringBuffer;->append(C)Ljava/lang/StringBuffer;

    const/4 v2, 0x1

    :cond_3
    :goto_1
    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    :cond_4
    invoke-virtual {v0, v3}, Ljava/lang/StringBuffer;->append(C)Ljava/lang/StringBuffer;

    move v2, v5

    goto :goto_1
.end method
